import axios from 'axios'

let instace = axios.create({
  baseURL:'/api',
  timeout: 3000
})

let instace2 = axios.create({
  baseURL:'/farm',
  timeout:3000
})


const http={
  install(Vue,options={}){
    let {timeout} = options
    // let instace = axios.create({
    //   baseURL:'/api',
    //   timeout:timeout || 3000
    // })
    instace.defaults.timeout = timeout
    Object.defineProperty(Vue.prototype,'$http_login',{
      value:instace
    })

   

    instace2.interceptors.response.use((response)=>{
      return response.data
    },(err)=>{
      return Promise.rej(err)
    })

    instace2.defaults.timeout = timeout

    Object.defineProperty(Vue.prototype,'$http',{
      value:instace2
    })
  }
}
export {instace as request_login,instace2 as request}
export default http